<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of settings
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Cms extends CI_Controller {

    //put your code here


    function cms() {
        parent :: __construct();
        $this->load->model('settings_model');
        $this->commoncall->check_admin_login();
    }

    function index() {
        $data['cms'] = $this->settings_model->get_cms();
        $this->load->view('admin/admin_cms', $data);
    }

    function get_cms($cmsID) {
                
        $data['cmsrow']=$this->settings_model->get_cms_by_id($cmsID);
        $this->load->view('admin/admin_cms',$data);
    }

    function update_cms() {
        if ($this->input->post('update_cms')) {
            $this->form_validation->set_rules('cmsid', 'cmsid', 'required|xss_clean');
            $id = trim($this->input->post('cmsid'));
            if ($this->form_validation->run()) {
                $data = array('meta_title'=>$this->input->post('metatitle'),
                              'meta_keyword'=>$this->input->post('metakeyword'),
                              'meta_description'=>$this->input->post('metadescription'),
                              'description'=>$this->input->post('cmsdescription')
                              );
                $this->db->where('id', $id);
                $this->db->update('cms', $data);
                redirect('admin/cms/get_cms/'. $id);
                
            }
           
        }
         $this->session->set_flashdata('message','All fields are mendatory');
         redirect('admin/cms/get_cms/'. $id);
    }
   
}
?>